<?php
function userInformation($ID){
    include("../includes/connection.php");

    $query ="SELECT * FROM accounts WHERE sNo =$ID";
    $result = mysql_query($query,$accounts) or die(mysql_error());
    $numrows = mysql_fetch_array($result);
    return "(".$numrows['username'].",".$numrows['sNo'].",".$numrows['lName'].",".$numrows['fName'].")";
}
function implodeAdder($add,$base){
        $explodeddata = explode(",",$base);
        if(in_array($add,$explodeddata)){
            return $base;
        }
        else{
            
            $newArray = array_push($explodeddata,$add);
            foreach($newArray as $string){
                $stringArray =  $stringArray. ",".$string;
            }
            return $stringArray;
        }
}
function scoreUpdater($userID,$PcriteriaID,$PgroupID){
    include("../includes/connection.php");
    $scoreInfoQueryTest ="SELECT * FROM studentscore WHERE gID = $PgroupID AND  criteriaID = $PcriteriaID AND userID = $userID ";
    $existTest = mysql_query($scoreInfoQueryTest) or die(""); 
    $elementExisTest=  mysql_num_rows($existTest);
    if($elementExisTest ==1){
        $elementTest =  mysql_fetch_array($existTest);
        return $elementTest['score'];
    }
    else{
        return -1;
    }
}
function scoretotal($userID,$PgroupID){
    include("../includes/connection.php");
    $scoreInfoQueryTest ="SELECT SUM(score) FROM studentscore WHERE userID = $userID AND  gID = $PgroupID";
    $existTest = mysql_query($scoreInfoQueryTest) or die(""); 
    $elementExisTest=  mysql_num_rows($existTest);
    if(isset($elementTest['SUM(score)'])){
        $elementTest =  mysql_fetch_array($existTest);
        return $elementTest['SUM(score)'];
    }
    else{
        return 0;
    }
}
function tep_session_register($variable) {
    global $session_started;

    if ($session_started == true) {
        if (PHP_VERSION < 4.3) {
            return session_register($variable);
        } else {
            if (isset($GLOBALS[$variable])) {
                $_SESSION[$variable] =& $GLOBALS[$variable];
            } else {
                $_SESSION[$variable] = null;
            }
        }
    }

    return false;
}
function tep_session_is_registered($variable) {
    if (PHP_VERSION < 4.3) {
        return session_is_registered($variable);
    } else {
        return isset($_SESSION) && array_key_exists($variable, $_SESSION);
    }
}

function tep_session_unregister($variable) {
    if (PHP_VERSION < 4.3) {
        return session_unregister($variable);
    } else {
        unset($_SESSION[$variable]);
    }
}
?>
